#include <iostream>
#include <thread>
#include <mutex>
using namespace std;

int   a = 0;
mutex mt;

void a1()
{
    unique_lock<std::mutex> lck(mt);
    a++;
    cout << a << endl;
}

void a2()
{
    unique_lock<std::mutex> lck(mt);
    while (a == 0)
    {
    }
    cout << a << endl;
}

int main(int argc, char const *argv[])
{
    thread th1(a2);
    thread th2(a1);
    th1.join();
    th2.join();

    return 0;
}